package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import dao.LogDao;
import domain.Log;
import domain.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogService {
    @Autowired
    private LogDao logDao;

    public PageInfo<Log> findLogAll(int pageNum, int pageSize, String username) {
        PageHelper.startPage(pageNum, pageSize);
        username = username == null ? null : "%" + username + "%";
        List<Log> all = logDao.findAll(username);
        PageInfo pageInfo = new PageInfo(all);
        return pageInfo;
    }

    public void addLog(Log log) {
        logDao.add(log);
    }

    public Log findLogById(int id) {
        return logDao.findById(id);
    }
}
